<template>
<table
    class="water-cp-container"
    border="1">
    <tr class="top-container">
        <td class="left">
            阴阳离子含量 基础数据
        </td>
        <td class="right">
            当前报告
        </td>
    </tr>
    <tr class="content-container">
        <td class="left">
            <div class="container">
                <ChartItem
                    v-for="(item,index) in baseDataList"
                    :key="index"
                    :itemData="item">
                </ChartItem>
            </div>
        </td>
        <td class="right">
            <div class="container">
                <ChartItem
                    v-for="(item,index) in dataList"
                    :key="index"
                    :itemData="item">
                </ChartItem>
            </div>
        </td>
    </tr>
    <tr class="bottom-container" v-if="false">
        <td
            colspan="2"
            class="container">
            低熟油型气
        </td>
    </tr>
</table>
</template>
<script>
/*
 阴阳离子含量展示页面
 */
import {randomColor} from "@/common/ColorTools";
import ChartItem from './components/ChartItem';
export default {
    components:{ChartItem},
    props:{
        currentReport:{  //当前选择的报告
            type:Object,
            default:()=>{
                return {};
            },
        },
        reports:{  //当前选择的报告列表
            type:Array,
            default:()=>[],
        },
        areas:{  //当前选择的地区
            type:Array,
            default:()=>[],
        },
        horizons:{  //当前选择的层位
            type:Array,
            default:()=>[],
        },
        fontColor:{
            type:String,
            default:'',
        },
        borderColor:{
            type:String,
            default:'',
        },
        chartBorderColor:{
            type:String,
            default:'',
        },
    },
    data() {
        this.nameConfigMap = {};  //颜色列表(保持颜色一致)
        return {
            baseDataList:[],  //基础数据
            dataList:[],  //数据列表
        };
    },
    watch:{
        reports:{
            handler(){
                this.$nextTick(()=>{
                    this.getReportData();
                    this.getBaseData();
                });
            },
            immediate:true,
        },
    },
    mounted(){
        // this.getBaseData();
    },
    methods:{
        computConfig(data = []){  //计算配置
            data = data || [];
            data.forEach(item=>{
                this.nameConfigMap[item.horizon] = this.nameConfigMap[item.horizon] || {
                    color:randomColor(),
                };
            });
        },
        getBaseData(){  //获取基础数据
            if(this.reports.lenth==0){
                this.baseDataList = [];
                return;
            }
            this.$Service.post(
                this.$Api.waterYinYang,
                {
                    "isbasic":1,
                    "type":11,
                    'area':this.areas.join(','),
                    'horizon':this.horizons.join(','),
                },
            ).then(res => {
                this.baseDataList = res.data.basicList || [];
            }).catch(() => {
                return;
            });
        },
        getReportData(){  //获取报告数据
            if(this.reports.lenth==0){
                this.dataList = [];
                return;
            }
            this.$Service.post(
                this.$Api.waterYinYang,
                {
                    "reportType":2,
                    "reportNo":this.reports.map(item=>item.reportNo).join(","),
                    "contenid":this.reports.map(item=>item.contenid).join(","),
                    'area':this.areas.join(','),
                    'horizon':this.horizons.join(','),
                    "type":11,
                },
            ).then(res => {
                this.dataList = res.data.selList || [];
            }).catch(() => {
                this.dataList = [];
                return;
            });
        },
    },
};
</script>
<style scoped lang="scss">
.water-cp-container{
    width: 100%;
    height: fit-content;
    text-align: left;
    color: var(--font-color);
    box-sizing: border-box;
    border-collapse: collapse;
    border-color: var(--border-color);
    border: 1px solid var(--border-color);
    table-layout:fixed;
    >tr{
        >td{
            &:last-child{
                width: 50%;
            }
        }
    }
    >.top-container{
        >td{
            font-size: 1.5rem;
            font-weight: bold;
            padding: 1rem;
            box-sizing: border-box;
            line-height: 1;
            box-sizing: border-box;
        }
    }
    >.content-container{
        >.left{
            >.container{
                max-height: 60vh;
                overflow: auto;
                display: grid;
                grid-template-columns: repeat(auto-fill,minmax(350px,1fr));
                grid-gap: 15px;
                padding: 5px;
                box-sizing: border-box;
            }
        }
        >.right{
            >.container{
                height: 100%;
                max-height: 60vh;
                overflow: auto;
                display: grid;
                grid-template-columns: repeat(auto-fill,minmax(350px,1fr));
                grid-gap: 15px;
                padding: 5px;
                box-sizing: border-box;
            }
        }
    }
    >.bottom-container{
        >.container{
            padding: 1.5rem 1rem;
            font-size: 1.5rem;
            color: #99a9bf;
            box-sizing: border-box;
            span{
                font-size: 1.7rem;
                color: var(--font-color);
            }
            .data{
                font-size: 2rem;
                color: #00c57a;
                font-weight: bold;
            }
        }
    }
}
</style>
